package pers.course.week7;

import java.util.LinkedList;
import java.util.Scanner;

class ListStack<T> {
    private LinkedList<T> ll = new LinkedList<>();
    public void push(T t) {
        this.ll.addFirst(t);
    }
    public T pop() {
        return this.ll.removeFirst();
    }
    public T peek() {
        T t = null;
        if (!this.ll.isEmpty()) {
            t = this.ll.getFirst();
        }
        return t;
    }
    public boolean isEmpty() {
        return this.ll.isEmpty();
    }
}
public class Match{
    public static void main(String[] args) {
        ListStack<Character> stack = new ListStack<Character>();
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        char[] strArray = str.toCharArray();
        boolean isMatch = true;
        for (Character c : strArray) {
            if (c == '(' || c == '[' || c == '{') {
                stack.push(c);
            } else {
                if (stack.isEmpty()) {
                    isMatch = false;
                    break;
                }
                if (c == ')' && stack.pop() != '(') {
                    isMatch = false;
                    break;
                }
                if (c == ']' && stack.pop() != '[') {
                    isMatch = false;
                    break;
                }
                if (c == '}' && stack.pop() != '{') {
                    isMatch = false;
                    break;
                }
            }
        }
        isMatch = stack.isEmpty();
        if (isMatch) {
            System.out.println("True");
        } else {
            System.out.println("False");
        }
    }
}
